home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / BenchMarks / ByteBenchmark / Run < prev   
Text File  |  1994-01-27  |  13KB  |  482 lines

  1. #! /bin/sh
  2. #################### set your defaults here ##############
  3. FLAVOR="" # flavor of UNIX: if not determined by script: SysV or BSD
  4. FULL_SUITE="dhry2 dhry2reg arithoh register short int long float double syscall pipe context1 spawn execl fstime C shell dc hanoi"
  5. ###############################################################################
  6. #  The BYTE UNIX Benchmarks - Release 3
  7. #          Module: Run   SID: 3.11 5/15/91 19:30:14
  8. #          
  9. ###############################################################################
  10. # Bug reports, patches, comments, suggestions should be sent to:
  11. #
  12. #    Ben Smith,            Tom Yager at BYTE Magazine
  13. #    ben@bytepb.byte.com       tyager@bytepb.byte.com
  14. # BIX:  bensmith              tyager
  15. #
  16. ###############################################################################
  17. #  Modification Log:
  18. # $Header: run,v 5.2 88/01/12 06:23:43 kenj Exp $
  19. #     Ken McDonell, Computer Science, Monash University
  20. #     August 1, 1983
  21. # 3/89 - Ben Smith - BYTE: globalized many variables, modernized syntax
  22. # 5/89 - commented and modernized. Removed workload items till they
  23. #        have been modernized. Added database server test.
  24. # 11/14/89 - Made modifications to reflect new version of fstime
  25. #        and elimination of mem tests.
  26. # 10/22/90 - Many tests have been flipped so that they run for
  27. #        a specified length of time and loops are counted.
  28. #  4/3/91 - Cleaned up and debugged several test parameters - Ben
  29. #  4/9/91 - Added structure for creating index and determing flavor of UNIX
  30. #  4/26/91 - Made changes and corrections suggested by Tin Le of Sony
  31. #  5/15/91 - Removed db from distribution
  32. #
  33. ###############################################################################
  34. ID="@(#)Run:3.11 -- 5/15/91 19:30:14";
  35. version="3.11"
  36. #######################################################################
  37. # General Purpose Benchmark
  38. # based on the work by Ken McDonell, Computer Science, Monash University
  39. #
  40. #  You will need ...
  41. #    awk cat cc chmod comm cp date dc df echo ed expr
  42. #    kill ls make mkdir rm sed test time touch tty umask who
  43. #       AND /bin/time
  44. #  to generate result indexes, you will also need ...
  45. #       join
  46. #
  47. #
  48. umask 022    # at least mortals can read root's files this way
  49. #
  50. if [ -z "$FLAVOR" ]
  51. then
  52.    # determine flavor of UNIX from number of lines generated by /bin/tim
  53.    Fcount=`/bin/time date 2>&1 | wc -l | sed 's/ //g'`
  54.    case "$Fcount"
  55.    in
  56.     2) FLAVOR="BSD";;
  57.     5) FLAVOR="SysV";;
  58.     *) echo "Flavor of UNIX is not known."
  59.        echo "Please define FLAVOR in Run script"
  60.        exit;;
  61.    esac
  62. fi
  63. #if SysV use 'uname -a' -- if BSD use 'hostname'
  64. if [ $FLAVOR = "SysV" ]
  65. then UNAME="uname -a"
  66. else UNAME="hostname"
  67. fi
  68. export FLAVOR
  69. # check that the required files are in the proper places
  70. if make check 
  71.         then :
  72.         else make all
  73. fi
  74. #
  75. #
  76. # establish full paths to directories
  77. PWD=`pwd`
  78. HOMEDIR=${HOMEDIR-.}
  79. cd $HOMEDIR
  80. HOMEDIR=`pwd`
  81. cd $PWD
  82.  
  83. BINDIR=${BINDIR-${HOMEDIR}/pgms}
  84. cd $BINDIR
  85. BINDIR=`pwd`
  86. cd $PWD
  87. # let's extend the path to this directory
  88. PATH="${PATH}:${BINDIR}"
  89.  
  90. SCRPDIR=${SCRPDIR-${HOMEDIR}/pgms}
  91. cd $SCRPDIR
  92. SCRPDIR=`pwd`
  93. cd $PWD
  94.  
  95. TMPDIR=${HOMEDIR}/tmp
  96. cd $TMPDIR
  97. TMPDIR=`pwd`
  98. cd $PWD
  99.  
  100. RESULTDIR=${RESULTDIR-${HOMEDIR}/results}
  101. cd $RESULTDIR
  102. RESULTDIR=`pwd`
  103. cd $PWD
  104.  
  105. TIMEACCUM=${TIMEACCUM-${RESULTDIR}/times}
  106.  
  107. TESTDIR=${TESTDIR-${HOMEDIR}/testdir}
  108. cd $TESTDIR
  109. TESTDIR=`pwd`
  110. cd $PWD
  111.  
  112. export BINDIR TMPDIR RESULTDIR PATH TESTDIR TIMEACCUM
  113. #
  114. cat ${BINDIR}/byte.logo # display banner
  115. rm -f ${TIMEACCUM}      # clean out old time accumulation file
  116. echo "kill -9 $$" > ${TMPDIR}/kill_run ; chmod u+x ${TMPDIR}/kill_run
  117. #
  118. arithmetic="arithoh register short int long float double"
  119. system="syscall pipe context1 spawn execl fstime"
  120. misc="C dc hanoi"
  121. dhry="dhry2 dhry2reg" # dhrystone loops
  122. load="shell" # cummulative load tests
  123. index="double dhry2 execl fstime context1 shell"
  124. #
  125. args="" # the accumulator for the bench units to be run
  126. runoption="N"
  127. # generate list of bench programs
  128. for word
  129. do  # do level 1
  130.     case $word
  131.     in
  132.   all)
  133.       ;;
  134.   arithmetic)
  135.       args="$args $arithmetic"
  136.       ;;
  137.   dhry)
  138.       args="$args $dhry"
  139.       ;;
  140.   load)
  141.       args="$args $load"
  142.       ;;
  143.   misc)
  144.       args="$args $misc"
  145.       ;;
  146.   speed)
  147.       args="$args $arithmetic $system"
  148.       ;;
  149.   system)
  150.       args="$args $system"
  151.       ;;
  152.   index)
  153.       args="$args $index"
  154.       ;;
  155.   -q|-Q)
  156.       runoption="Q" #quiet
  157.       shift
  158.       ;;
  159.   -v|-V)
  160.       runoption="V" #verbose
  161.       shift
  162.       ;;
  163.   -d|-D)
  164.       runoption="D" #debug
  165.       shift
  166.       ;;
  167.   *)
  168.       args="$args $word"
  169.       ;;
  170.     esac
  171.  
  172. done # end do level 1
  173. #if no benchmark units have be specified, do them all 
  174. # the - option of set implies no options; any list following
  175. # becomes the line arguments (replacing any that may exist)
  176. set - $args
  177. if test $# -eq 0  #no arguments specified
  178.    then
  179.    set - $FULL_SUITE
  180. fi
  181.  
  182. if test "$runoption" = 'D'
  183. then
  184.   set -x
  185.   set -v
  186. fi
  187.  
  188. date=`date`
  189. TMPTIMES=${TMPDIR}/$$.tmp
  190. LOGFILE=${RESULTDIR}/log
  191. REPORTLOG=${RESULTDIR}/report
  192. #add old log to accumulated log or move it
  193. if test -w ${RESULTDIR}/log
  194. then
  195.    if test -w ${RESULTDIR}/log.accum
  196.    then
  197.       cat ${RESULTDIR}/log >> ${RESULTDIR}/log.accum
  198.       rm ${RESULTDIR}/log
  199.    else
  200.       mv ${RESULTDIR}/log ${RESULTDIR}/log.accum
  201.    fi
  202. fi
  203. echo "|  BYTE UNIX Benchmarks (Version $version)" >>$LOGFILE
  204. echo "|  System --" `$UNAME` >>$LOGFILE
  205. echo "|  Start Benchmark Run: `date`" >>$LOGFILE
  206. echo "|  " `who | wc -l` "interactive users." >>$LOGFILE
  207. #if not specified, do each bench 6 iterations
  208. iter=${iterations-6}
  209. if test $iter -eq 6
  210. then
  211.   longloop="1 2 3 4 5 6"
  212.   shortloop="1 2 3"
  213. else  # generate list of loop numbers
  214.   short=`expr \( $iter + 1 \) / 2`
  215.   longloop=""
  216.   shortloop=""
  217.   while test $iter -gt 0
  218.   do # do level 1
  219.        longloop="$iter $longloop"
  220.        if test $iter -le $short
  221.        then
  222.          shortloop="$iter $shortloop"
  223.        fi
  224.        iter=`expr $iter - 1`
  225.   done # end do level 1
  226. fi #loop list genration
  227. ####################################################################
  228. ############## the major control loop ##############################
  229. ####################################################################
  230. for bench # line argument processing
  231. do # do level 1
  232.     # set some default values
  233.     prog=${BINDIR}/$bench  # the bench name is default program
  234.     paramlist="#"          # a dummy parameter to make anything run
  235.     testdir="${TESTDIR}"   # the directory in which to run the test
  236.     prepcmd=""             # preparation command or script
  237.     parammsg=""
  238.     repeat="$longloop"
  239.     stdout="$LOGFILE"
  240.     stdin=""
  241.     options=""
  242.     logmsg=""
  243.     cleanopt="-l $TMPTIMES"
  244.     bgnumber=""
  245.     trap "${SCRPDIR}/cleanup.sh -L $LOGFILE -a; exit" 1 2 3 15
  246.     echo "" >>$LOGFILE
  247.     ###################### select the bench specific values ##########
  248.     case $bench
  249.     in
  250.   dhry2)
  251.     options=${dhrytime-10}
  252.     logmsg="Dhrystone 2 without register variables"
  253.     ;;
  254.  
  255.   dhry2reg)
  256.     options=${dhrytime-10}
  257.     logmsg="Dhrystone 2 using register variables"
  258.     ;;
  259.  
  260.   arithoh|register|short|int|long)
  261.     options=${arithtime-10}
  262.     logmsg="Arithmetic Test (type = $bench)"
  263.     ;;
  264.  
  265.   float|double)
  266.     options=${arithtime-10}
  267.     logmsg="Arithmetic Test (type = $bench)"
  268.     ;;
  269.  
  270.   syscall)
  271.     options=${systime-10}
  272.     logmsg="System Call Overhead Test"
  273.     ;;
  274.  
  275.   context1)
  276.     options=${systime-10}
  277.     logmsg="Pipe-based Context Switching Test"
  278.     ;;
  279.  
  280.   pipe)   
  281.     options=${systime-10}
  282.     logmsg="Pipe Throughput Test"
  283.     ;;
  284.  
  285.   spawn)  
  286.     options=${systime-10}
  287.     logmsg="Process Creation Test"
  288.     ;;
  289.  
  290.   execl)  
  291.     options=${systime-10}
  292.     logmsg="Execl Throughput Test"
  293.     ;;
  294.  
  295.   fstime) 
  296.     logmsg='Filesystem Throughput Test ($param second test)'
  297.     where=${where-${TMPDIR}}
  298.     cleanopt="-f $TMPTIMES"
  299.     options='$param '"$where"
  300.     paramlist=${seconds-"10 30"}
  301.     parammsg='Test Time: $param secs'
  302.     ;;
  303.  
  304.   C)  
  305.     logmsg="C Compiler Test"
  306.     prog="looper ${looper-60} cc cctest.c"
  307.     stdout=/dev/null
  308.     repeat="$shortloop"
  309.     cleanopt="-m $TMPTIMES"
  310.     rm -f ${TESTDIR}/cctest.o ${TESTDIR}/a.out
  311.     ;;
  312.  
  313.   shell)
  314.     logmsg='Shell scripts ($param concurrent)'
  315.     prog="looper ${looper-60} multi.sh"
  316.     repeat="$shortloop"
  317.     stdout=/dev/null
  318.     paramlist=${background-"1 2 4 8 "}
  319.     parammsg='$param concurrent background processes'
  320.     bgnumber='$param'
  321.     cleanopt="-m $TMPTIMES"
  322.     ;;
  323.  
  324.   dc)  
  325.     logmsg="Dc: sqrt(2) to 99 decimal places"
  326.     prog="looper ${looper-60} dc"
  327.     stdin=dc.dat
  328.     stdout=/dev/null
  329.     cleanopt="-m $TMPTIMES"
  330.     ;;
  331.  
  332.   hanoi)  
  333.     options=${systime-10}
  334.     stdout=/dev/null
  335.     logmsg="Recursion Test--Tower of Hanoi"
  336.     parammsg='$param Disk Problem:'
  337.     ;;
  338.  
  339.   *)   ${BINDIR}/cleanup.sh -L $LOGFILE -r "run: unknown benchmark \"$bench\" \n Known benchmarks are: \n $FULL_SUITE" -a
  340.     exit 1
  341.     ;;
  342. esac
  343. ################################################################
  344. ###################### the main task ###########################
  345. ###################### run the bench ###########################
  346. ################################################################
  347. # each of those variables are now used in a general way
  348. #
  349.     for param in $paramlist
  350.     do   # level 2
  351.       param=`echo $param | sed 's/_/ /g'` # be sure that spaces are used
  352.       eval Lmsg='"'$logmsg'"'
  353.       eval opt='"'$options'"'         # evaluate any vars in options
  354.       eval prep='"'$prepcmd'"'         # evaluate any prep command
  355.       eval bg='"'$bgnumber'"'         # evaluate bgnumber string
  356.       rm -f $TMPTIMES             # remove any tmp files
  357.  
  358.       # if the test requires mulitple concurrent processes,
  359.       # prepare the background process string (bgstr)
  360.       # this is just a string of "+"s that will provides a
  361.       # parameter count for a "for" loop
  362.       bgstr=""
  363.       if test "$bg" != ""
  364.       then
  365.       count=`expr "$bg"`
  366.           while test $count -gt 0
  367.           do
  368.           bgstr="+ $bgstr"
  369.           count=`expr $count - 1`
  370.       done
  371.       fi
  372.       #
  373.       echo "TEST|$Lmsg" >>$TMPTIMES
  374.       echo "FLAVOR|${FLAVOR}" >>$TMPTIMES
  375.       if [ "$runoption" != 'Q' ]
  376.       then
  377.           echo ""
  378.           if [ $FLAVOR = "SysV" ]
  379.          then echo "$Lmsg \c"
  380.          else echo -n "$Lmsg "
  381.           fi
  382.     
  383.       fi
  384.       for i in $repeat             # loop for the specified number
  385.       do  # do depth 3
  386.           if [ "$runoption" != 'D' ]  # level 1
  387.       then
  388.         # regular Run - set logfile to go on signal
  389.             trap "${BINDIR}/cleanup.sh -L $LOGFILE -i $i $cleanopt -a; exit" 1 2 3 15
  390.       else
  391.             trap "exit" 1 2 3 15
  392.       fi #end level 1
  393.       # make an attempt to flush buffers
  394.       sync; sync; sleep 10
  395.       # display heartbeat
  396.           if [ "$runoption" != 'Q' ]
  397.       then
  398.           if [ $FLAVOR = "SysV" ]
  399.              then echo " $i\c"      # display repeat number
  400.              else echo -n " $i"
  401.           fi
  402.       fi
  403.       pwd=`pwd`                     # remember where we are
  404.       cd $testdir                   # move to the test directory
  405.       if [ "$runoption" = "V" ]
  406.       then
  407.         echo
  408.         echo "BENCH COMMAND TO BE EXECUTED:"
  409.         echo "$prog $opt"
  410.       fi
  411.  
  412.       # execute any prepratory command string
  413.       if [ -n "$prep" ]
  414.       then
  415.         $prep 2>&1 >>$stdout 
  416.       fi
  417.       ############ THE BENCH IS TIMED ##############
  418.           if test "$stdin" = ""  
  419.           then # without redirected stdin
  420.              /bin/time $prog $opt $bgstr 2>>$TMPTIMES >>$stdout
  421.           else # with redirected stdin
  422.              /bin/time $prog $opt $bgstr <$stdin 2>>$TMPTIMES >>$stdout
  423.           fi 
  424.       /bin/time $benchcmd
  425.       ###############################################
  426.       cd $pwd                    # move back home
  427.           status=$?                  # save the result code
  428.           if test $status != 0 # must have been an error
  429.           then
  430.            if test -f $TMPTIMES # is there an error file ?
  431.            then
  432.                 cp $TMPTIMES ${TMPDIR}/save.$bench.$param
  433.             ${SCRPDIR}/cleanup.sh -L $LOGFILE -i $i $cleanopt -r \
  434.            "run: bench=$bench param=$param fatalstatus=$status" -a
  435.            else
  436.             ${SCRPDIR}/cleanup.sh -L $LOGFILE -r \
  437.            "run: bench=$bench param=$param fatalstatus=$status" -a
  438.            fi 
  439.            exit # leave the script if there are errors
  440.           fi # end  level 1
  441.       done # end do depth 3 - repeat of bench
  442.       if [ "$runoption" != 'D' ]
  443.       then
  444.         ${SCRPDIR}/cleanup.sh -L $LOGFILE $cleanopt # finalize this bench
  445.                          # with these options
  446.                          # & calculate results
  447.       fi
  448.     done # end do depth 2 - end of all options for this bench
  449.  
  450.     ########### some specific cleanup routines ##############
  451.     case $bench
  452.     in
  453.       C)
  454.       rm -f ${TESTDIR}/cctest.o ${TESTDIR}/a.out
  455.       ;;
  456.  
  457.       fstime)
  458.       sync; sleep 20
  459.       ;;
  460.     esac
  461.     if [ "$runoption" != 'Q' ]
  462.     then
  463.        echo ""
  464.     fi
  465. done # end do level 1  - all benchmarks requested
  466. ########## a few last items for the end ##############
  467. echo "" >>$LOGFILE
  468. echo "End Benchmark Run: `date`" >>$LOGFILE
  469. echo " " `who | wc -l` "interactive users." >>$LOGFILE
  470. # create the report
  471. ${SCRPDIR}/report.sh $LOGFILE > $REPORTLOG 
  472. ${SCRPDIR}/index.sh ${SCRPDIR}/index.base $LOGFILE >> $REPORTLOG
  473. if [ "$runoption" != 'Q' ]
  474. then
  475.   echo ""
  476.   echo "=============================================================="
  477.   cat $REPORTLOG
  478. fi
  479.  
  480. exit
  481. ########################### Amen ######################
  482.